package andanyoung.springcloud.order.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.Random;

@RestController
public class OrderController {

    @GetMapping("order/{uid}")
    public String getOrder(@PathVariable long uid) {
        return "ORDER: " + uid;
    }

    @GetMapping("failureOrder/{uid}")
    public String getFailureOrder(@PathVariable long uid) {
        Random r = new Random(System.currentTimeMillis());
        int i = r.nextInt(5);
        return uid + "- Random:" + i + " - " + 1 / i;
    }
}
